﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LIM.controller;
using LIM.model;
using Microsoft.Reporting.WinForms;
namespace LIM.report
{
    public partial class frm_RPPhieuNhanMau : Form
    {
        public frm_RPPhieuNhanMau()
        {
            InitializeComponent();
        }
        CRM_PhieuNhanMauController controller = new CRM_PhieuNhanMauController();
        public int RowIDPhieuNhanMau = 7;
        private void frm_RPBaoGia_Load(object sender, EventArgs e)
        {
            if (RowIDPhieuNhanMau != 0)
            {
                tbl_CRM_PhieuNhanMau phieuNhanmau = controller.loadPhieuNhanMauByID(RowIDPhieuNhanMau);
                string KhachHang = "";
                if (controller.GetKH(phieuNhanmau.RowIDKhachHang) != null)
                {
                    KhachHang = controller.GetKH(phieuNhanmau.RowIDKhachHang);
                }
                string NguoiLienHe = "";
                if (controller.GetLienHe(phieuNhanmau.RowIDLienLac) != null)
                {
                    NguoiLienHe = controller.GetLienHe(phieuNhanmau.RowIDLienLac);
                }
                #region Paramater
                ReportParameter[] report = new ReportParameter[]
                {
                    new ReportParameter("NguoiLienHe",NguoiLienHe),
                    new ReportParameter("KhachHang",KhachHang),
                    new ReportParameter("Email",phieuNhanmau.Email),
                    new ReportParameter("DT",phieuNhanmau.SoDienThoai),
                    new ReportParameter("MaSoMau",phieuNhanmau.MaPhieuNhanMau),
                    new ReportParameter("DiaChi",phieuNhanmau.DiaChi),
                    new ReportParameter("MaSoThue",phieuNhanmau.MaSoThue),
                    new ReportParameter("LoaiMau",""),
                    new ReportParameter("SLMau",""),
                    new ReportParameter("Fax",phieuNhanmau.SoFax),
                    new ReportParameter("PhiThuNghiem",""),
                    new ReportParameter("BangChu",""),
                    new ReportParameter("SendEmail","true"),
                    new ReportParameter("SendFax","true"),
                    new ReportParameter("SendDT","true"),
                    new ReportParameter("SendThu","true"),
                    new ReportParameter("SendTrucTiep","true"),
                    new ReportParameter("NgayGioNhan",DateTime.Now.ToString()),
                    new ReportParameter("NgayGioTra",DateTime.Now.ToString()),
                    new ReportParameter("NhaThauPhu",""),
                    new ReportParameter("YeuCauKhac",""),
                    new ReportParameter("UngTruoc",""),
                    new ReportParameter("ConLai",""),
                };
                #endregion
                vPhieuNhanMauBindingSource.DataSource = controller.LoadPhieuNhanMauByRowIDPhieuNhanMau(RowIDPhieuNhanMau);
                reportViewer1.LocalReport.SetParameters(report);
                reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
                reportViewer1.ZoomMode = ZoomMode.Percent;
                reportViewer1.ZoomPercent = 100;
                this.reportViewer1.RefreshReport();
            }
            
        }
    }
}
